<?php $this -> load -> view('common/head_open'); ?>
<script src="<?php echo SKIN_URL_JS; ?>/jquery-autogrow.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	var email_exp = /\S+@\S+\.\S+/;
	var check_email_letter=/^\s*[a-zA-Z0-9_.@\-\s]+\s*$/;
	email=$("#email");
	password=$("#password");
	reconfirming_password=$("#reconfirming_password");
	$(email).change(function(){
		if($(this).val()!='')
		{
		 	if(check_email_letter.test($(this).val())==false||$(this).val().indexOf(" ")>0||email_exp.test($(this).val())==false)
		 	{
				$(".error").html("<?php if(isset($javscript_error['invalid_email'])) echo $javscript_error['invalid_email']  ?>");
				$(this).focus();
				return false;
		 	}
		 	else
		 	{
				$(".error").html('');
			}
		}
		else
		{
			$(".error").html('');
		}
	});
	//$(email).blur(function(){
		//$(".error").html('');
		//checkEmail($(this).val());
	//});
	$(password).keyup(function()
	{
		$('.error').html(checkStrength($(this).val()));
		
	});
	$(reconfirming_password).keyup(function()
	{
		if($(this).val() != $(password).val())
		{
			$(".error").html("<?php if(isset($javscript_error['password_not_match'])) echo $javscript_error['password_not_match']  ?>");
	        $(this).focus();
	        return false;
		}
		else{
			$(".error").html('');
		}
	});
	
	$("#email").change(function(){
		if($(this).val()=='')	
		{
			$(".error").html("<?php if(isset($javscript_error['email'])) echo $javscript_error['email']  ?>");
	        $(this).focus();
	        return false;
		}
		else if(email_exp.test($(this).val())==false)
		{
			$(".error").html("<?php if(isset($javscript_error['invalid_email'])) echo $javscript_error['invalid_email']  ?>");
			$(this).focus();
			return false;
		}
	});
	$("#password").focusout(function(){
		$('.error').html('');
		if($(this).val()=='')	
		{
			$(".error").html("<?php if(isset($javscript_error['password'])) echo $javscript_error['password']  ?>");
	       // $(this).focus();
	        return false;
		}
	});
	$("#reconfirming_password").focusout(function(){
		if($(this).val()=='')	
		{
			$(".error").html("<?php if(isset($javscript_error['re_password'])) echo $javscript_error['re_password']  ?>");
	        //$(this).focus();
	        return false;
		}
	});
	
	function checkEmail(q)
	{
		$.ajax({
			url:'<?php echo base_url() ?>'+'check_mail',
            type : 'POST',
            data : {'search' : q},
			success: function (data){
				switch(data) {
                    case ('TRUE'):
                        $('.error').html("<?php echo $this->lang->line('account_creation_duplicate_email');  ?>");
                        $("#email").focus();
						return false;  
                        break;

                    case ('FALSE'):
                        $('.error').html();
                        break;
                }
			}
		});
	}
	
	function checkStrength(password)
	{
		//initial strength
		var strength = 0
		if (password.length == 0) { 
			$('.error').html();
			return false; 
		}
		//if the password length is less than 5, return message.
		if (password.length < 8) { 
		$('.error').html("short");
		return 'Minimum password length is 8'; 
		   return false
		}
		//if length is 8 characters or more, increase strength value
		/*if (password.length > 7) strength += 1
		//if password contains both lower and uppercase characters, increase strength value
		if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  strength += 1
		//if it has numbers and characters, increase strength value
		if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/))  strength += 1 
		//if it has one special character, increase strength value
		if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/))  strength += 1
		//if it has two special characters, increase strength value
		if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
		//now we have calculated strength value, we can return messages
		//if value is less than 2
		if (strength < 2 )
		{
			$('.error').html("weak");
			return 'Weak'			
		}
		else if (strength == 2 )
		{
			$('.error').html("good");
			return 'Good'		
		}
		else
		{
			$('.error').html("strong");
			return 'Strong'
		}*/
	}
	
	
//--------------------//
  $("#join_as_continue").click(function(){
	var email_exp = /\S+@\S+\.\S+/;
    email=$("#email");
	password=$("#password");
	reconfirming_password=$("#reconfirming_password");
	
	if(email.val()==''||email.val()==null||email.val()=='Email Id')
	{
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['email'])) echo $javscript_error['email']  ?>");
		email.focus();
		return false;
	}
	else if(email_exp.test(email.val())==false)
	{ 
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['invalid_email'])) echo $javscript_error['invalid_email']  ?>");
		email.focus();
		return false;
	}
	else if(password.val()=='')
	{
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['password'])) echo $javscript_error['password']  ?>");
		password.focus();
		return false;
	}
	else if(password.val().length < 8)
	{
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['min_password_length'])) echo $javscript_error['min_password_length']  ?>");
		password.focus();
		return false;
	}
	
	else if(reconfirming_password.val()==''||reconfirming_password.val()==null)
	{
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['re_password'])) echo $javscript_error['re_password'] ?>");
		reconfirming_password.focus();
		return false;
	}
	else if(reconfirming_password.val()!=password.val())
	{
		$(".error").html('<samp>*</samp>'+"<?php if(isset($javscript_error['password_not_match'])) echo $javscript_error['password_not_match']  ?>");
		reconfirming_password.focus();
		return false;
	}
	else
	{
		$("#join_as_form1").submit();
	}
  });
});
</script>
<?php $this -> load -> view('common/head_close'); ?>
<!--wrapper starts-->
<section class="wrapper">
	<!--header starts-->
	<?php $this->load->view('common/header'); ?>
	<!--header closed-->
	<!--Container starts-->
	<div class="container-fluid">
		
		<section class="Container" style="padding-left: 96px; padding-right: 184px;">
			<h1>Zigya <?php echo $h1_title; ?></h1>
			<!--information starts-->
			<div class="col-md-10 col-sm-10 col-lg-10 col-xs-12 zero-padding custom-margin-bottom">
				<!--information starts-->
				<div class="information">
					<!--information_inner starts-->
					<?php $this->load->view('common/information_inner_continue'); ?>
					<!--information_inner closed-->
					<!--information_nav starts-->
					<?php $this -> load -> view('common/information_nav'); ?>
					<!--information_nav closed-->
					<div class="clear"></div>
				</div>
			</div>
			<!--information closed-->
			<!--information_aside starts-->
			<?php $this->load->view('common/information_aside'); ?>
			<!--information_aside closed-->
			<div class="clear"></div>
		</section>
		
	</div>
	<!--Container closed-->
</section>
<!--wrapper closed-->
<?php $this -> load -> view('common/footer'); ?>